﻿using System;

class Customer
{
    static void Main(string[] args)
    {
        double sum = 960;
        Graph food1 = GraphSimpleFactory.CreateFood("长方形");
        Graph food2 = GraphSimpleFactory.CreateFood("正方形");
        Graph food3 = GraphSimpleFactory.CreateFood("正方形");
        Graph food4 = GraphSimpleFactory.CreateFood("正方形");
        Graph food5 = GraphSimpleFactory.CreateFood("长方形");
        Graph food6 = GraphSimpleFactory.CreateFood("长方形");
        Graph food7 = GraphSimpleFactory.CreateFood("正方形");
        Graph food8 = GraphSimpleFactory.CreateFood("正方形");
        Graph food9 = GraphSimpleFactory.CreateFood("长方形");
        Graph food10 = GraphSimpleFactory.CreateFood("正方形");
        Console.WriteLine("总面积为" + sum);
        Console.Read();
    }
}

public abstract class Graph
{
    public abstract void Print();
}

public class changfangxing : Graph
{
    double chang = 10;
    double kuan = 9;
    public double GetSO()
    {
        return this.chang * this.kuan;
    }
    public override void Print()
    {
        Console.WriteLine("一个长方形！");
    }
}

public class zhengfangxing : Graph
{
    double bianchang = 10;
    public double GetSO()
    {
        return this.bianchang * this.bianchang;
    }
    public override void Print()
    {
        Console.WriteLine("一个正方形！");
    }
}

public class GraphSimpleFactory
{
    public static Graph CreateFood(string type)
    {
        Graph graph = null;
        if (type.Equals("正方形"))
        {
            graph = new changfangxing();
        }
        else if (type.Equals("长方形"))
        {
            graph = new zhengfangxing();
        }
        return graph;
    }
}
